import message_pb2

my_message = message_pb2.MyMessage(id=123, name="Test", value=0)
serialized_data = my_message.SerializeToString()

with open("serialized_data.bin", "wb") as f:
    f.write(serialized_data)